#ifndef REMOTECONTROL_H
#define REMOTECONTROL_H

#define SLEEP_TIME 250
#define REMOTE_CONTROL_PORT 9877

#include<QThread>
#include<string>
#include<QMutex>
#include"Communication.h"

#include "workingthread.hpp"
#include "comminucationhandler.hpp"
#include "XmlProccessor.h"

class RemoteControl: public WorkingThread
{
    Q_OBJECT
    enum Command{Run=0,Kill,Ping,ResetPC,TransmitGramar,RollBackGrammar};

public:
    RemoteControl(ComminucationHandler *handler);
    ~RemoteControl();
    void stop();
    bool init();
protected:
    void run();
public Q_SLOTS:
    void runProgramm();
    void killProgramm();
    void pingProgramm();
    void ResetComputer();
    void transmitGrammar(std::string grammarText);
    void rollbackGrammar();
private:
    void commitCommand(const RemoteControl::Command c,const char * arg=0);
    std::string ParseMessage(std::string);
    volatile bool running;
Q_SIGNALS:
    void statusRecieved(QString status);


};

#endif
